/*-----------------------------------------------------------------------------------
Name: Sangyoon Park
Date: January 23 2023
This do file does : 
	Create variable labels and export codebook
-----------------------------------------------------------------------------------*/
clear all
set matsize 10000
set maxvar 10000
set more off


#delim ;


*** Load dataset;

import excel "${raw_path}/INTERMEDIARY_COMBINETRADE_CLEAN.xlsx", firstrow;


*** Label dataset;

lab data "This file contains intermediary reports on trade with down-stream buyers";

*** Label variables;

lab var traderid "unique id of trader";
lab var strata "[Base] strata assigned to trader";
lab var st_tgroup "[Base] treatment group assigned to trader";
lab var follow"followup survey round (0 = baseline)";
lab var num"buyer number in survey";
lab var sell_volume"percent of total volume sold to buyer";
lab var sell_price"price sold to buyer";
lab var sell_type"buyer's type";
lab var sell_contract"have contract with buyer";
lab var sell_exp"experience with buyer";
lab var sell_market"product sold to country/market";

** Label values;

drop if sell_volume == .;

label define typelabel 1 "Collector" 2 "Export Enterprise" 3 "Foreign Buyer" 4 "Domestic Retailer";
label values sell_type typelabel;
tab sell_type, gen(dum_type);

label define marketlabel 1 "China" 2 "Asia" 3 "EU/US" 4 "Domestic";
label values sell_market marketlabel;
tab sell_market, gen(dum_market);

*** Save dataset;

save "${data_path}/INTERMEDIARY_COMBINETRADE_CLEAN", replace;

*** Create codebook for datafile;

log using "${out_path}/codebook_intermediary_combinetrade_clean.log", replace;

codebook,compact;

log close;

